<?php
require("DBOperations.php");

class User
{
	private $user_id;
	private $user_name;
	private $email;
	private $password;
	private $born_date;
	private $gender;
	private $register_date;
	private $activated;
	private $avatar;
	private $db;
	
	private $content = array();
	private $comment = array();
	private $report = array();
	
	public function __construct($user_name="")
	{
		$this->db = new DBOperations();
		$arrUser = DBOperations::getUserFromDB($user_name);
		$this->user_id = $arrUser["user_id"];
		$this->user_name = $arrUser["user_name"];
		$this->email = $arrUser["email"];
		$this->password = $arrUser["password"];
		$this->born_date = $arrUser["born_date"];
		$this->gender = $arrUser["gender"];
		$this->register_date = $arrUser["register_date"];
		$this->activated = $arrUser["activated"];
		$this->avatar = "";		
	}
	
	public static function checkUserNameAndPassword($user_name, $password)
	{
		if (DBOperations::does_user_name_exist($user_name) < 1)
		return "Невалидно потребителско име!";
		if( $password != DBOperations::getUserPassword($user_name))
		return "Грешна парола!";
		
		return true;
	}
	
	public function getUser_id() 
	{
		return $this->user_id; 
	} 
	public function getUser_name() 
	{ 
		return $this->user_name; 
	} 
	public function getEmail() 
	{
		return $this->email; 
	} 
	public function getPassword() 
	{
		return $this->password; 
	} 
	public function getBorn_date() 
	{
		return $this->born_date; 
	} 
	public function getGender() 
	{
		return $this->gender; 
	} 
	public function getRegister_date() 
	{
		return $this->register_date; 
	} 
	public function getActivated() 
	{
		return $this->activated; 
	} 
	public function setUser_id($x) 
	{
		$this->user_id = $x; 
	} 
	public function setUser_name($x) 
	{
		$this->user_name = $x; 
	} 
	public function setEmail($x) 
	{
		$this->email = $x; 
	} 
	public function setPassword($x) 
	{
		$this->password = $x; 
	} 
	public function setBorn_date($x) 
	{
		$this->born_date = $x; 
	} 
	public function setGender($x) 
	{
		$this->gender = $x; 
	} 
	public function setRegister_date($x) 
	{
		$this->register_date = $x; 
	} 
	public function setActivated($x) 
	{
		$this->activated = $x; 
	} 
	
}
?>